package com.spi.config;

import com.xxl.job.core.handler.IJobHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.Map;

@Component
public class JobHandlerPrinter {

    @Autowired
    private ApplicationContext applicationContext;

    @PostConstruct
    public void printJobHandlers() {
        Map<String, IJobHandler> jobHandlerMap = applicationContext.getBeansOfType(IJobHandler.class);
        System.out.println("已注册的JobHandler列表：");
        for (Map.Entry<String, IJobHandler> entry : jobHandlerMap.entrySet()) {
            System.out.println("JobHandler名称: " + entry.getKey() + ", 类型: " + entry.getValue().getClass().getName());
        }
    }
}
